package com.example.leetcode.DynamicProgramming;

/**
 * @Description TODO
 * @date 2021/6/30 8:57
 * @Author liuzhihui
 * @Version 1.0
 */
public class Solution_5_122 {
    public static void main(String[] args) {

    }
    // 思路：只要后一天的价格大于前一天就有利润
    // 把所有这种情况加起来
    public int maxProfit(int[] prices) {
        int maxProfit = 0;
        for (int i = 0; i < prices.length; i++) {
            maxProfit = maxProfit + Math.max(0, prices[i + 1] - prices[i]);
        }
        return maxProfit;
    }

}
